package com.example.husbandry_online.adapter;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.husbandry_online.view.HusbandryFragment;
import com.example.husbandry_online.view.IndividualFragment;
import com.example.husbandry_online.view.LivebroadcastFragment;
import com.example.husbandry_online.view.PracticeFragment;

public class HomePageFragmentAdapter extends FragmentStateAdapter {
    Context context;
    public HomePageFragmentAdapter(@NonNull FragmentActivity fragmentActivity) {
                super(fragmentActivity);
    }

    public HomePageFragmentAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    public HomePageFragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        Log.e("test","执行createFragment");
        switch (position){
            case 0:
                return new LivebroadcastFragment();
            case 1:
                return new HusbandryFragment();
            default:
                return new PracticeFragment();
        }
    }

    @Override
    public int getItemCount() {
        return 3;
    }
}
